package ch.trainingtest.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import ch.trainingtest.base.entity.BaseEntity;
import ch.trainingtest.common.Constants;
import ch.trainingtest.common.NamedQueryConstants;

@Entity
@Table(name = "TTask")
@NamedQuery(name = NamedQueryConstants.TASK_GET_ALL_TASKS,
			query = "SELECT t FROM Task t")
public class Task extends BaseEntity{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 3008969910043744138L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID")
	private int id;
	
	@Column(name = "description")
	private String description;
	
	public List<TaskHistory> getListTaskHistory() {
		return listTaskHistory;
	}


	public void setListTaskHistory(List<TaskHistory> listTaskHistory) {
		this.listTaskHistory = listTaskHistory;
	}

	@ManyToOne
	@JoinColumn(name = "createdBy")
	private User createdBy;	
	
	@OneToMany(mappedBy = "task")
	private List<TaskHistory> listTaskHistory;
	
	@Column(name = "assigneeID")
	private int assigneeID;
	
	@Column(name = "title")
	private String title;
	
	@Column (name = "status")
	private int status;

	
	public Task() {
		super();
		// TODO Auto-generated constructor stub
	}

	
	public Task(String description, int assigneeID, String title, int status) {
		this.description = description;
		this.assigneeID = assigneeID;
		this.title = title;
		this.status = status;
	}


	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public User getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(User createdBy) {
		this.createdBy = createdBy;
	}

	public int getAssigneeID() {
		return assigneeID;
	}

	public void setAssigneeID(int assigneeID) {
		this.assigneeID = assigneeID;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}
	
	
	
}
